package thread;

import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;

/**
 * sleep方法要求我们必须处理中断异常
 * 当一个线程调用sleep方法处于睡眠阻塞的过程中如果该线程的interrupt方法
 * 被盗用，睡眠阻塞会被中断，sleep会抛出异常
 */
public class SleepDemo2 {
    public static void main(String[] args) {
        Thread lin = new Thread("林永健") {
            public void run() {
                System.out.println(getName() + ":刚美容完睡一会吧~");
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                    System.out.println("干嘛呢！干嘛呢！干嘛呢！都破相了！");
                }
                System.out.println(getName() + "醒了");
            }
        };
        Thread huang =new Thread("黄大锤"){
            public void run(){
                System.out.println("开砸！大锤80小锤40");
                try {
                    for (int i = 0; i <4 ; i++) {
                        Thread.sleep(1000);
                        System.out.println(getName()+"80！80！80！");
                    }
                } catch (InterruptedException e) {

                }
                System.out.println("完事！哐当！！");
            }

        };
        lin.start();
        huang.start();
    }
}
